<html>
<head><meta charset="utf-8"><title>Debugging a clippy Stack Overflow · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html">Debugging a clippy Stack Overflow</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="237468197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237468197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> llogiq <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237468197">(May 05 2021 at 09:49)</a>:</h4>
<p>Hi folks. I've started working on <a href="https://getsynth.com">https://getsynth.com</a> and naturally wanted to see how clippy fares with our codebase. Turns out it overflows its stack. After trying too long getting a debugger to run on clippy, I decided to at least bisect the error and found that this commit introduces it: <a href="https://github.com/openquery-io/synth/commit/955714b8c7d5038a8765f4f96b528a73e0dbf204">https://github.com/openquery-io/synth/commit/955714b8c7d5038a8765f4f96b528a73e0dbf204</a> – Now I'd really like to reduce the scope of our search further and would greatly appreciate some assistance.</p>



<a name="237470527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237470527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> xFrednet <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237470527">(May 05 2021 at 10:08)</a>:</h4>
<p>I would guess that it could have something to do with statement comparison using <code>SpanlessEq</code> as that is the only recursive functionality in Clippy that I know of. But looking at the linked commit also makes me doubt that. <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="237474087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237474087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> llogiq <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237474087">(May 05 2021 at 10:44)</a>:</h4>
<p>I think I could try to bisect the commit by cherry-picking individual changes.</p>



<a name="237476426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237476426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237476426">(May 05 2021 at 11:05)</a>:</h4>
<p>Did you try this with different versions of Clippy? If not, which version are you currently using?</p>



<a name="237480283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237480283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237480283">(May 05 2021 at 11:40)</a>:</h4>
<div class="codehilite"><pre><span></span><code>#177 0x000055555567dab8 in &lt;core::iter::adapters::map::Map&lt;I,F&gt; as core::iter::traits::iterator::Iterator&gt;::try_fold ()
#178 0x00005555555cbc14 in clippy_lints::matches::redundant_pattern_match::type_needs_ordered_drop ()
#179 0x000055555567dab8 in &lt;core::iter::adapters::map::Map&lt;I,F&gt; as core::iter::traits::iterator::Iterator&gt;::try_fold ()
#180 0x00005555555cbc14 in clippy_lints::matches::redundant_pattern_match::type_needs_ordered_drop ()
</code></pre></div>



<a name="237482434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237482434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237482434">(May 05 2021 at 11:57)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[derive(Default)]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">A</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">a</span>: <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">b</span>: <span class="nc">T</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Ok</span><span class="p">(</span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Ok</span>::<span class="o">&lt;</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="p">()</span><span class="o">&gt;</span><span class="p">(</span><span class="n">A</span>::<span class="o">&lt;</span><span class="nb">String</span><span class="o">&gt;</span>::<span class="n">default</span><span class="p">())</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="237487155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237487155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> llogiq <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237487155">(May 05 2021 at 12:35)</a>:</h4>
<p><span class="user-mention" data-user-id="264664">@flip1995</span> I use the clippy version as of 1.53.0-nightly (42816d61e 2021-04-24). @tm this might be it.</p>



<a name="237489592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237489592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237489592">(May 05 2021 at 12:53)</a>:</h4>
<p>Ok, I guess this is this PR then: <a href="https://github.com/rust-lang/rust-clippy/pull/6568">https://github.com/rust-lang/rust-clippy/pull/6568</a></p>
<p>I'll verify that this PR is the cause and will revert it and sync it back to Rust, so that this doesn't get into beta. Thanks <span class="user-mention" data-user-id="352985">@tm</span> !</p>



<a name="237489794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237489794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237489794">(May 05 2021 at 12:55)</a>:</h4>
<p>(Just noticed, that beta is already branched. So I will do a backport-revert of this PR after the release of Clippy 0.1.52 tomorrow.)</p>



<a name="237491540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237491540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237491540">(May 05 2021 at 13:08)</a>:</h4>
<p>tracked here: <a href="https://github.com/rust-lang/rust-clippy/issues/7169">rust-clippy#7169</a></p>



<a name="237494423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237494423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237494423">(May 05 2021 at 13:27)</a>:</h4>
<p>ooh this looks like a fun problem!</p>



<a name="237496753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237496753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237496753">(May 05 2021 at 13:42)</a>:</h4>
<p>Revert PR open: <a href="https://github.com/rust-lang/rust-clippy/issues/7170">rust-clippy#7170</a> (We want this in Clippy, but not having a stack overflow in beta tomorrow is more important right now. So if someone wants to find and fix this properly, please do so!)</p>



<a name="237497712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237497712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237497712">(May 05 2021 at 13:49)</a>:</h4>
<p>Seems like it should be straightfoward to fix the recursion in <code>type_needs_ordered_drop</code>...</p>



<a name="237499072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237499072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237499072">(May 05 2021 at 13:58)</a>:</h4>
<p>commented on PR</p>



<a name="237499152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237499152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237499152">(May 05 2021 at 13:59)</a>:</h4>
<p>needs fmt (my fix)</p>



<a name="237501512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Debugging%20a%20clippy%20Stack%20Overflow/near/237501512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Debugging.20a.20clippy.20Stack.20Overflow.html#237501512">(May 05 2021 at 14:13)</a>:</h4>
<p>Awesome, that fixed it! Updating the PR now.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>